package doantotnghiep.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NamedNativeQuery;

@Entity
@NamedNativeQuery(name = "increaseNumberMedicine", query = "call increaseNumberMedicine();", resultClass = Category.class)
@Table(name="NhomSanPham")
public class Category {

	private int id;
	private String categoryName;
    private Set<Medicament> medicaments = new HashSet<Medicament>(); 
    private int numberMedicine;
    private int status;
    
	@Id 
	@GeneratedValue
	@Column(name = "MaNSP")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "TenNSP")
	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}
	
	@OneToMany(mappedBy = "category", fetch = FetchType.LAZY) 
	@Fetch(FetchMode.JOIN)
	public Set<Medicament> getMedicaments() {
		return medicaments;
	}

	public void setMedicaments(Set<Medicament> medicaments) {
		this.medicaments = medicaments;
	}
	
	@Column(name = "SoDuocPham")
	public int getNumberMedicine() {
		return numberMedicine;
	}

	public void setNumberMedicine(int numberMedicine) {
		this.numberMedicine = numberMedicine;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

}
